<template>
  <div class="container">
    <h1>Vue3 Number Scroll Component</h1>
    
    <div class="demo-section">
      <h2>Basic Usage</h2>
      <div class="demo-box">
        <NumberScroll :value="basicValue" />
      </div>
      <button @click="changeBasicValue">Change Value</button>
    </div>

    <div class="demo-section">
      <h2>Custom Duration</h2>
      <div class="demo-box">
        <NumberScroll :value="customDurationValue" :duration="2000" />
      </div>
      <button @click="changeCustomDurationValue">Change Value</button>
    </div>

    <div class="demo-section">
      <h2>Custom Format</h2>
      <div class="demo-box">
        <NumberScroll :value="formatValue" format="$#,##0.00" />
      </div>
      <button @click="changeFormatValue">Change Value</button>
    </div>

    <div class="demo-section">
      <h2>Large Numbers</h2>
      <div class="demo-box">
        <NumberScroll :value="largeValue" format="#,##0" />
      </div>
      <button @click="changeLargeValue">Change Value</button>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import NumberScroll from './components/NumberScroll.vue'

export default defineComponent({
  name: 'App',
  components: {
    NumberScroll
  },
  setup() {
    const basicValue = ref(123)
    const customDurationValue = ref(456)
    const formatValue = ref(99.99)
    const largeValue = ref(1000000)

    const changeBasicValue = () => {
      basicValue.value = Math.floor(Math.random() * 1000)
    }

    const changeCustomDurationValue = () => {
      customDurationValue.value = Math.floor(Math.random() * 1000)
    }

    const changeFormatValue = () => {
      formatValue.value = Math.round(Math.random() * 10000) / 100
    }

    const changeLargeValue = () => {
      largeValue.value = Math.floor(Math.random() * 10000000)
    }

    return {
      basicValue,
      customDurationValue,
      formatValue,
      largeValue,
      changeBasicValue,
      changeCustomDurationValue,
      changeFormatValue,
      changeLargeValue
    }
  }
})
</script>

<style>
.container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.demo-section {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.demo-box {
  font-size: 2rem;
  margin: 1rem 0;
  min-height: 3rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

button {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 10px 20px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  border-radius: 4px;
}

button:hover {
  background-color: #45a049;
}
</style>